package com.drd.dt.back.service.Impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.drd.dt.common.Constant;
import com.drd.dt.util.ResultUtil;
import com.drd.dt.back.dao.OrderManagerMapper;
import com.drd.dt.back.service.IOrderManageService;
import com.drd.dt.common.SuccessResultEnum;
import com.drd.dt.common.tips.Tip;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Created by 86514 on 2019/4/10.
 */
@Transactional
@Service("orderManageService")
public class OrderManagerServiceImpl implements IOrderManageService {

    @Autowired
    private OrderManagerMapper orderManagerMapper;


    @Override
    public Tip list(Map<Object, Object> map) throws Exception{
        Integer offset = Integer.valueOf(map.get("offset").toString());
        Integer pageSize = Constant.PAGE_SIZE_20;
        Integer pageNum = offset / pageSize + 1;
        Page page = new Page(pageNum, pageSize);
        List<Map> list = orderManagerMapper.getOrderList(page,map);
        page.setRecords(list);
        return ResultUtil.result(SuccessResultEnum.SUCCESS.getCode(), SuccessResultEnum.SUCCESS.getMessage(),page);
    }
}
